#include "XPacket.h"

bool XPacket::playerRunCommand(Player& player, const string& cmd) {
    CommandContext context = CommandContext(
        cmd,
        std::make_unique<PlayerCommandOrigin>(PlayerCommandOrigin(player))
    );
    ll::service::getMinecraft()->getCommands().executeCommand(context);
    return true;
}

bool XPacket::runCommand(const string& cmd) {
    CommandContext context = CommandContext(
        cmd,
        std::make_unique<ServerCommandOrigin>(
            ServerCommandOrigin("Server", ll::service::getLevel()->asServer(), CommandPermissionLevel::Internal, 0)
        )
    );
    ll::service::getMinecraft()->getCommands().executeCommand(context);
    return true;
}